#include<iostream>
#include<string>
using namespace std;
const int maxn=2005,mod=1000000007;
int T,n;
int f[maxn][maxn+maxn],g[maxn][maxn+maxn];
string s,t;
int main(){
cin>>T;
while(T--){
cin>>n;
cin>>s>>t;
for(int i=1;i<n;i+=2){
s[i]^=1;
t[i]^=1;
}
s=" "+s;
t=" "+t;
f[0][n]=1;
for(int i=1;i<=n;i++)
for(int j=n-i;j<=n+i;j++)
for(int x=0;x<=1;x++)
for(int y=0;y<=1;y++)
if((x^1)!=s[i]-'0'&&(y^1)!=t[i]-'0'){
f[i][j+x-y]=(f[i][j+x-y]+f[i-1][j])%mod;
g[i][j+x-y]=((g[i][j+x-y]+g[i-1][j])%mod+1ll*abs(j-n)*f[i-1][j])%mod;
}
cout<<g[n][n]<<'\n';
for(int i=0;i<=n;i++)
for(int j=0;j<=n+n;j++)
f[i][j]=g[i][j]=0;
}
return 0;
}
1438A - Specific Tastes of Andre | 1711C - Color the Picture |
1194C - From S To T | 110B - Lucky String |
1114A - Got Any Grapes | 224B - Array |
125B - Simple XML | 567B - Berland National Library |
431B - Shower Line | 282C - XOR and OR |
1582B - Luntik and Subsequences | 609A - Флеш-карты |
1207A - There Are Two Types Of Burgers | 371C - Hamburgers |
343B - Alternating Current | 758B - Blown Garland |
1681B - Card Trick | 1592A - Gamer Hemose |
493D - Vasya and Chess | 1485A - Add and Divide |
337B - Routine Problem | 1392D - Omkar and Bed Wars |
76E - Points | 762C - Two strings |
802M - April Fools' Problem (easy) | 577B - Modulo Sum |
1555B - Two Tables | 1686A - Everything Everywhere All But One |
1469B - Red and Blue | 1257B - Magic Stick |